package com.httpDemo.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.httpDemo.doMain.User;

/**
 * 使用注解的方式
 * 
 * @author Administrator
 *
 */
//@Mapper //一般在启动类上加@MapperScan注解
public interface UserDao {

	@Delete("delete from sys_user u where u.id=#{id}")
	int deleteById(Integer id);

	@Insert("insert into sys_user(name,address) values(#{name},#{address})")
	int save(User user);

	@Update("update sys_user u set u.name=#{name},u.address=#{address} where u.id=#{id}")
	int update(User user);

	@Select("select u.id,u.name,u.address from sys_user u where u.id=#{id}")
	User findById(Integer id);

	@Select("select u.id,u.name,u.address from sys_user u")
	List<User> findAll();
}
